let t = require;
let e = module
let o = e.exports;
o.default = e.exports;

'use strict';
console.log("start");
var _n105,
    i =
        (this && this.__extends) ||
        ((_n105 = function n(t, e) {
            return (_n105 =
                Object.setPrototypeOf ||
                ({
                    __proto__: []
                }
                    instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) {
                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                    }
                })(t, e);
        }),
            function (t, e) {
                function o() {
                    this.constructor = t;
                }
                _n105(t, e),
                    (t.prototype =
                        null === e ?
                            Object.create(e) :
                            ((o.prototype = e.prototype), new o()));
            }),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var i,
                r = arguments.length,
                a =
                    r < 3 ?
                        e :
                        null === n ?
                            (n = Object.getOwnPropertyDescriptor(e, o)) :
                            n;
            if (
                'object' ==
                (typeof Reflect === 'undefined' ?
                    'undefined' :
                    typeof (Reflect)) &&
                'function' == typeof Reflect.decorate
            )
                a = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--) {
                    (i = t[s]) &&
                        (a = (r < 3 ? i(a) : r > 3 ? i(e, o, a) : i(e, o)) || a);
                }
            return r > 3 && a && Object.defineProperty(e, o, a), a;
        };
Object.defineProperty(o, '__esModule', {
    value: !0
}),
    (o.GuidePanel = void 0);
var a = t('UIPanel'),
    s = t('UIViewRes'),
    c = t('UILayer'),
    l = t('UIMrg'),
    u = t('ComUtils'),
    h = t('AbsGuideAction'),
    p = t('GuideTipsCom'),
    f = t('PlayerMrg'),
    d = t('MathUtils'),
    g = t('MergeMrg'),
    _ = t('LangCfg'),
    y = cc._decorator,
    C = y.ccclass,
    m =
        (y.property,
            (function (t) {
                function e() {
                    return (null !== t && t.apply(this, arguments)) || this;
                }
                return (
                    i(e, t),
                    (e.prototype.onInit = function () {
                        t.prototype.onInit.call(this);
                        var e = cc.view.getVisibleSize();
                        (this.black = u.default.getNode(this.view, 'mask/black')),
                            (this.black.width = 3 * e.width),
                            (this.black.height = 3 * e.height),
                            (this.line = u.default.getNode(this.view, 'line')),
                            (this.mask = u.default.getNode(this.view, 'mask')),
                            (this.hand = u.default.getNode(this.view, 'hand')),
                            (this._tipsCom = new p.GuideTipsCom(
                                u.default.getNode(this.view, 'tips')
                            )),
                            (this._maskCom = this.mask.getComponent(cc.Mask)),
                            (this.hot = u.default.getNode(this.view, 'hot')),
                            this.hot.on(
                                cc.Node.EventType.TOUCH_END,
                                this.onTouchTargetHandler,
                                this
                            ),
                            (this.hot.active = !1),
                            this.removeListenerTouch();
                    }),
                    (e.prototype.onLang = function () {
                        u.default.getComponent(
                            cc.Label,
                            this.view,
                            'tips/msg/banyatu/New Label'
                        ).string = _.LangCfg.ins.getContent(201800);
                    }),
                    (e.prototype.onClose = function () {
                        this._act && (this._act.targetOff(this), (this._act = null)),
                            this.tips &&
                            (this.tips.targetOff(this),
                                this.tips.removeFromParent(!0),
                                (this.tips = null)),
                            (this.hot.active = !1),
                            this._target &&
                            this._target instanceof cc.Node &&
                            (this._target.targetOff(this), (this._target = null));
                    }),
                    (e.prototype.onShow = function () {
                        (this.mask.width = 0),
                            (this.mask.height = 0),
                            (this.mask.x = 0),
                            (this.mask.y = 0),
                            this.startGuide(this.getData());
                    }),
                    (e.prototype.startGuide = function (t) {
                        this._target = this;
                        var e = cc.js.getClassByName('Guide' + t);
                        (this._act = new e()),
                            this._act.on(
                                h.GuideActionEvent.Complete,
                                this.onCompleteHandler,
                                this
                            ),
                            this._act.on(
                                h.GuideActionEvent.StepChanged,
                                this.onStepChangedHandler,
                                this
                            ),
                            this._act.on(
                                h.GuideActionEvent.TargetChanged,
                                this.onTargetChangedHandler,
                                this
                            ),
                            this._act.start(t),
                            (this.view.active = !this._act.hide),
                            (this.mask.opacity = this._act.alpha),
                            (this._blTween = !1);
                    }),
                    (e.prototype.onCompleteHandler = function (t) {
                        f.PlayerMrg.ins.guideComplete(t), l.UIMrg.close(this);
                    }),
                    (e.prototype.onStepChangedHandler = function (t) {
                        if (this._act) {
                            // 获取提示内容
                            const tipContent = _.LangCfg.ins.getContent(t.tips);

                            // 根据提示内容是否存在处理提示组件
                            if (t.tips && tipContent.length > 0) {
                                this._tipsCom.active = true;
                                this._tipsCom.setTips(tipContent);
                                this._tipsCom.setType(t.site);
                                this._tipsCom.setKind(t.kind);
                                this._tipsCom.setIcon(t.extData);
                                this._tipsCom.view.opacity = 0;
                                cc.tween(this._tipsCom.view)
                                    .to(0.2, { opacity: 255 })
                                    .start();
                            } else {
                                this._tipsCom.view.opacity = 0;
                                this._tipsCom.active = false;
                            }

                            // 根据形状设置遮罩类型
                            switch (t.shape) {
                                case 0:
                                case 1:
                                    this._maskCom.type = cc.Mask.Type.RECT;
                                    break;
                                case 2:
                                    this._maskCom.type = cc.Mask.Type.ELLIPSE;
                                    break;
                            }

                            if(this._act.guide.id == 7 && this._act.guide.step == 1){
                                this._act.guide.opacity = 114;
                            }
                            // 更新黑色遮罩层透明度
                            this.black.opacity = this._act.guide.opacity;
                        }
                    }),
                    (e.prototype.onTargetChangedHandler = function (t) {
                        var e = this.hand.getComponent(cc.Animation);
                        if (
                            ((this.hot.active = !1),
                                (this.hand.active = !1),
                                (this.line.active = !1),
                                this.black.targetOff(this),
                                this.hot.targetOff(this),
                                (this._blTween = !1),
                                (this._path = null),
                                (this._index = 0),
                                this._target &&
                                this._target instanceof cc.Node &&
                                this._target.targetOff(this),
                                t && t instanceof cc.Node)
                        )
                            switch (((this._target = t), this._act.guide.kind)) {
                                case 0:
                                    (this.hot.active = !0),
                                        this.hot.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchEmptyHandler,
                                            this
                                        );
                                    break;

                                case 1:
                                    (this.hot.active = !0),
                                        this.hot.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchTargetHandler,
                                            this
                                        );
                                    break;

                                case 2:
                                    (this.hot.active = !1),
                                        this._target.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchTargetHandler,
                                            this
                                        ),
                                        this.black.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchEmptyHandler,
                                            this
                                        ),
                                        (this.hand.active = !0),
                                        e.play('GuideHand');
                                    break;

                                case 3:
                                    (this.hot.active = !1),
                                        (this.hand.active = !0),
                                        (this.line.active = !0),
                                        e.play('GuideHandStop'),
                                        this.drawLine(this._act.target, this._act.to),
                                        this._target.on(
                                            cc.Node.EventType.TOUCH_START,
                                            this.onTouchTargetHideLineHandler,
                                            this
                                        ),
                                        this._target.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchTargetShowLineHandler,
                                            this
                                        ),
                                        this._target.on(
                                            cc.Node.EventType.TOUCH_CANCEL,
                                            this.onTouchTargetShowLineHandler,
                                            this
                                        );
                                    break;

                                case 4:
                                    (this.hand.active = !0),
                                        e.play('GuideHandStop'),
                                        this.drawLine(
                                            this._act.target,
                                            g.MergeMrg.grids[5][1],
                                            !1
                                        );
                            }
                        else if (null == t) {
                            switch (this._act.guide.kind) {
                                case 1:
                                    this.hot.on(
                                        cc.Node.EventType.TOUCH_END,
                                        this.onTouchTargetHandler,
                                        this
                                    );
                                    break;

                                default:
                                    this.hot.on(
                                        cc.Node.EventType.TOUCH_END,
                                        this.onTouchEmptyHandler,
                                        this
                                    );
                            }
                            (this.hot.active = !0), (this._target = null);
                        }
                    }),
                    (e.prototype.onTouchTargetHideLineHandler = function () {
                        this.hand.active = !1;
                    }),
                    (e.prototype.onTouchTargetShowLineHandler = function () {
                        (this._index = 0),
                            (this.hand.x = this._path[0].x + this.line.x),
                            (this.hand.y = this._path[0].y + this.line.y),
                            this.nextPoint(),
                            (this.hand.active = !0);
                    }),
                    (e.prototype.drawLine = function (t, e, o) {
                        void 0 === o && (o = !0);
                        var n = this.line.getComponent(cc.Graphics);
                        if ((n.clear(), t && e)) {
                            for (
                                var i = this.view.convertToNodeSpaceAR(
                                    t.convertToWorldSpaceAR(cc.Vec2.ZERO)
                                ),
                                r = this.view.convertToNodeSpaceAR(
                                    e.view.convertToWorldSpaceAR(cc.Vec2.ZERO)
                                ),
                                a = cc.v2(r.x - i.x, r.y - i.y),
                                s = cc.v2(0.7 * a.x + 100, 0.7 * a.y + 80),
                                c = d.default.bezier2([cc.Vec2.ZERO, s, a], 17),
                                l = 0; l < c.length; l += 2
                            ) {
                                n.moveTo(c[l].x, c[l].y),
                                    n.lineTo(c[l + 1].x, c[l + 1].y);
                            }
                            var u = Math.atan2(
                                c[c.length - 2].y - c[c.length - 1].y,
                                c[c.length - 2].x - c[c.length - 1].x
                            ),
                                h = u + 30 * d.default.Deg2Rad,
                                p = u - 30 * d.default.Deg2Rad,
                                f = c[c.length - 1].x + 20 * Math.cos(h),
                                g = c[c.length - 1].y + 20 * Math.sin(h);
                            n.moveTo(c[c.length - 1].x, c[c.length - 1].y),
                                n.lineTo(f, g),
                                (f = c[c.length - 1].x + 20 * Math.cos(p)),
                                (g = c[c.length - 1].y + 20 * Math.sin(p)),
                                n.moveTo(c[c.length - 1].x, c[c.length - 1].y),
                                n.lineTo(f, g),
                                n.stroke(),
                                (this._path = c),
                                (this._index = 0),
                                (this.line.x = i.x),
                                (this.line.y = i.y),
                                (this.hand.x = this._path[0].x + this.line.x),
                                (this.hand.y = this._path[0].y + this.line.y),
                                this.nextPoint();
                        }
                    }),
                    (e.prototype.nextPoint = function (t) {
                        void 0 === t && (t = 0),
                            this._path &&
                            (this._index++,
                                this._index >= this._path.length &&
                                ((this._index = 1),
                                    (this.hand.x = this._path[0].x + this.line.x),
                                    (this.hand.y = this._path[0].y + this.line.y)),
                                (this._tx = this._path[this._index].x + this.line.x),
                                (this._ty = this._path[this._index].y + this.line.y),
                                (this._radian = Math.atan2(
                                    this._ty - this.hand.y,
                                    this._tx - this.hand.x
                                )),
                                (this._distance = d.default.distance2(
                                    this.hand.x,
                                    this.hand.y,
                                    this._tx,
                                    this._ty
                                )),
                                t > 0 && ((this._distance -= t), this.updateLocation(t)));
                    }),
                    (e.prototype.updateLocation = function (t) {
                        var e = d.default.to(
                            this.hand.x,
                            this.hand.y,
                            this._radian,
                            t
                        );
                        (this.hand.x = e.x), (this.hand.y = e.y);
                    }),
                    (e.prototype.onUpdate = function (t) {
                        if (
                            this._act &&
                            !this._act.isDestroy &&
                            (this._act.update(t),
                                this.draw(this._target),
                                this._path && this.hand.active)
                        ) {
                            var e = 300 * t;
                            if (this._distance > 0)
                                this.updateLocation(e), (this._distance -= e);
                            else
                                for (; this._distance <= 0;) {
                                    (this.hand.x = this._tx),
                                        (this.hand.y = this._ty),
                                        this.nextPoint(Math.abs(this._distance));
                                }
                        }
                    }),
                    (e.prototype.draw = function (t) {
                        // 刷新提示组件
                        this._tipsCom.refresh();

                        // 缓存节点、遮罩和引导配置
                        const targetNode = t;
                        const maskNode = this.mask;
                        const guideConfig = this._act.guide;

                        if (targetNode && targetNode instanceof cc.Node) {
                            // 获取目标节点的世界坐标，并转换为当前视图的节点坐标
                            let targetWorldPos = cc.v2();
                            targetWorldPos = targetNode.convertToWorldSpaceAR(targetWorldPos);
                            const targetViewPos = this.view.convertToNodeSpaceAR(targetWorldPos);

                            // 处理遮罩动画
                            if (!this._blTween && targetNode.width > 0) {
                                const targetBoundingBox = targetNode.getBoundingBoxToWorld();
                                maskNode.width = 0;
                                maskNode.height = 0;
                                cc.tween(maskNode)
                                    .to(0.2, {
                                        width: targetBoundingBox.width + this._act.augmentWidth,
                                        height: targetBoundingBox.height + this._act.augmentHeight
                                    })
                                    .start();
                                this._blTween = true;
                            }

                            // 处理手部位置
                            if (guideConfig.kind === 2) {
                                this.hand.x = targetViewPos.x;
                                // if (targetViewPos.x + 50 > 330) {
                                //     this.hand.x = targetViewPos.x;
                                // } else {
                                //     this.hand.scaleX = 1; 
                                //     this.hand.x = targetViewPos.x + 50;
                                // }
                                this.hand.y = targetViewPos.y;
                            }

                            // 处理提示组件位置
                            if (this._tipsCom.active) {
                                this._tipsCom.refresh();
                                switch (guideConfig.site) {
                                    case 0:
                                        this._tipsCom.view.setPosition(this._act.location);
                                        break;
                                    case 1:
                                        this._tipsCom.view.y = targetViewPos.y + targetNode.height / 2 + 30 + this._act.offsetY + this._act.augmentHeight / 2;
                                        this._tipsCom.view.x = targetViewPos.x + this._act.offsetX;
                                        break;
                                    case 2:
                                        this._tipsCom.view.y = targetViewPos.y - targetNode.height / 2 - 30 - this._act.offsetY + this._act.augmentHeight / 2;
                                        this._tipsCom.view.x = targetViewPos.x + this._act.offsetX;
                                        break;
                                    case 3:
                                        this._tipsCom.view.y = targetViewPos.y + this._act.offsetY;
                                        this._tipsCom.view.x = targetViewPos.x - targetNode.width / 2 - 30 - this._act.offsetX + this._act.augmentWidth / 2;
                                        break;
                                    case 4:
                                        this._tipsCom.view.y = targetViewPos.y + this._act.offsetY;
                                        this._tipsCom.view.x = targetViewPos.x + targetNode.width / 2 + 30 + this._act.offsetX + this._act.augmentWidth / 2;
                                        break;
                                }
                            }

                            // 更新遮罩位置
                            maskNode.x = targetViewPos.x;
                            maskNode.y = targetViewPos.y;
                        } else {
                            // 目标节点无效时，重置遮罩和提示组件位置
                            maskNode.width = 0;
                            maskNode.height = 0;
                            this._tipsCom.view.setPosition(this._act.location);
                        }
                    }),
                    (e.prototype.onTouchEmptyHandler = function () { }),
                    (e.prototype.onTouchTargetHandler = function () {
                        this.next();
                    }),
                    (e.prototype.next = function () {
                        this._act &&
                            ((this._target = this),
                                (this._path = null),
                                (this._index = 0),
                                (this.view.active = !this._act.hide),
                                (this.mask.opacity = this._act.alpha),
                                this._act.next(),
                                this.update(cc.director.getDeltaTime()));
                    }),
                    (e.RES = new s.UIViewRes(
                        'GuideView',
                        'Guide',
                        c.UILayer.GuideLayer
                    )),
                    r([C('GuidePanel')], e)
                );
            })(a.default));
(o.GuidePanel = m), console.log("end");
module.exports = e.exports;